package com.me.collector;

import java.util.ArrayList;

import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.Shape;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.me.collector.Definitions.EntityCategory;

public class StaticObject {
	
	protected Body body;
	protected short category = (short)EntityCategory.Static.getValue();
	protected short mask = (short)((short)EntityCategory.Item.getValue() | (short)EntityCategory.Hero.getValue());
	
	public StaticObject()
	{
		
	}
	
	public StaticObject(World world, Physics physics, ArrayList<Vector2> polygons)
	{
		BodyDef bodyDef = new BodyDef();
        bodyDef.position.set(new Vector2(0, -10));
        body = world.createBody(bodyDef);
        PolygonShape box = new PolygonShape();
        Vector2 boxPolygons[] = polygons.toArray(new Vector2[polygons.size()]);
        for(Vector2 v:boxPolygons)
        	v = new Vector2(v.x * Definitions.WORLD_TO_BOX, v.y * Definitions.WORLD_TO_BOX);
        box.set(boxPolygons);
        FixtureDef f = new FixtureDef();
		f.shape = box;
		f.density = physics.getDensity();
		f.friction = physics.getFriction();
		f.restitution = physics.getRestitution();
		f.filter.categoryBits = category;
		f.filter.maskBits = mask;
		body.createFixture(f);
        box.dispose();
	}
	
	public void setShapes(World world, ArrayList<Shape> shapes)
	{
		BodyDef bodyDef = new BodyDef();
        bodyDef.position.set(new Vector2(0, -10));
        body = world.createBody(bodyDef);
        for(Shape s:shapes)
        	body.createFixture(s, 0.0f);
        
        // Set Mesh
	}
}
